from core.page.login_page import LoginPage
from core


# 导入其他页面类...

class PageFactory:
    """页面工厂，根据页面名称创建对应的页面实例"""
    _page_mapping = {
        'login': LoginPage,
        'register': RegisterPage,
        # 新增页面在这里添加映射
    }

    @classmethod
    def create_page(cls, page_name: str, driver):
        """创建页面实例"""
        page_class = cls._page_mapping.get(page_name.lower())
        if not page_class:
            raise ValueError(f"未找到页面: {page_name}")
        return page_class(driver)

    @classmethod
    def register_page(cls, page_name: str, page_class):
        """动态注册新页面"""
        cls._page_mapping[page_name.lower()] = page_class